package com.yanyun.yczyy.api.config;

import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

@Slf4j
@Configuration
public class AppConfig {
    @Bean(name = "xunGengDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.hikari.xungeng")
    public HikariDataSource initSqlServerDataSource() {
        return new HikariDataSource();
    }

    @Bean(name = "yczyyDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.hikari.yczyy")
    public HikariDataSource initOracleDataSource() {
        return new HikariDataSource();
    }

    @Bean(name = "ctpDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.hikari.ctp")
    public HikariDataSource initCtpDataSource() {
        return new HikariDataSource();
    }

    @Bean(name = "xunGeng")
    public JdbcTemplate initXunGengJdbcTemplate(@Qualifier("xunGengDataSource") HikariDataSource sqlserverDataSource) {
        return new JdbcTemplate(sqlserverDataSource);
    }

    @Bean(name = "yczyy")
    public JdbcTemplate initYczyyJdbcTemplate(@Qualifier("yczyyDataSource") HikariDataSource oracleDataSource) {
        return new JdbcTemplate(oracleDataSource);
    }

    @Bean(name = "ctp")
    public JdbcTemplate initCtpJdbcTemplate(@Qualifier("ctpDataSource") HikariDataSource oracleDataSource) {
        return new JdbcTemplate(oracleDataSource);
    }

}
